package ar.edu.utn.frba.dds.tp.ui;

import org.uqbar.arena.actions.MessageSend;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.widgets.Button;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.windows.WindowOwner;

import ar.edu.utn.frba.dds.tp.code.Asientos.AsientoDeVuelo;

@SuppressWarnings("serial")
public class AccionSobreReservarWindow extends ResultadosAccionesWindow {

	private AsientoDeVuelo asiento;

	public AccionSobreReservarWindow(WindowOwner owner, BuscarWindow model) {
		super(owner, model);
		this.asiento=model.getModelObject().getAsientoSeleccionado();
	}

	@Override
	protected void buildAviso(Panel mainPanel) {
		Panel aviso = new Panel(mainPanel);
		aviso.setLayout(new HorizontalLayout());
		
		new Label(aviso).setText("El asiento " + asiento.getNumeroDeAsiento());
		new Label(aviso).setText(" ya se encuentra reservado.");
		new Label(new Panel(mainPanel).setLayout(new HorizontalLayout())).setText("¿Qué desea hacer?");
	}

	@Override
	protected void addActions(Panel actionsPanel) {
		new Button(actionsPanel)
			.setCaption("SobreReservar")
			.onClick(new MessageSend(this, "sobreReservar"));
		new Button(actionsPanel)
			.setCaption("Seguir Buscando")
			.onClick(new MessageSend(this, "close"));
	}
	
	public void sobreReservar(){
		this.asiento.agregarSobreReserva(getModelObject().getUser());
		close();
	}

}
